/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Table;

import java.util.List;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Administrator
 */
public class myTableModel extends DefaultTableModel {

    private HeadUnit[] columnInfo;

    private myTableModel() {
    }

    public myTableModel(Object[][] data, Object[] columnNames, HeadUnit[] columnInfo) {
        super(data, columnNames);
        this.columnInfo = columnInfo;
    }
    public myTableModel(HeadUnit[] columnInfo) {
        super();
        this.columnInfo = columnInfo;
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        if (column == 0) {
            List<List<Object>> datalist = this.getDataVector();
            if (datalist.get(row).get(0) == null || datalist.get(row).get(0).equals("")) {
                return true;
            } else {
                return false;
            }
        } else {
            return this.columnInfo[column].isEditable();
        }
//        return super.isCellEditable(row, column);
    }

    public static myTableModel getInstance() {
        return myTableModelHolder.INSTANCE;
    }

    private static class myTableModelHolder {

        private static final myTableModel INSTANCE = new myTableModel();
    }
}
